<%--
  Created by IntelliJ IDEA.
  User: 21933
  Date: 2021/1/21
  Time: 20:44
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script src="${pageContext.request.contextPath}/layui/layui.js"></script>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/layui/css/layui.css">
</head>
<body>
<%--时间筛选框--%>
<form>
    <div class="layui-inline">
<%--        姓名搜索框--%>
        <div class="layui-inline">
            <label class="layui-form-label">请输入姓名</label>
            <div class="layui-input-inline">
                <input type="text" name="title" lay-verify="title" id="staffname" autocomplete="off" placeholder="请输入姓名" class="layui-input">
            </div>
        </div>
<%--        日期搜索框--%>
        <div class="layui-inline">
            <label class="layui-form-label">请选择范围</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" id="test16" name="date"  placeholder="开始 到 结束">
            </div>
        </div>
<%--      提交重置--%>
        <div class="layui-input-inline">
            <a  class="layui-btn"  id="demo1">立即提交</a>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
<%--申请历史表--%>
    <table class="layui-hide" id="allOut" lay-filter="allOut"></table>

<%--右侧工具栏--%>
    <script type="text/html" id="historyBarDemo">
        <a class="layui-btn layui-btn-normal" lay-event="allAuditInfo">查看详情</a>
    </script>

<%--模板--%>
    <script type="text/html" id="statusTem">

    </script>
</body>
<script>
    layui.use(['table','jquery','laydate','layer','form'], function(){
        var table = layui.table;
        var $=layui.jquery;
        var laydate=layui.laydate;
        var layer=layui.layer;
        var form=layui.form;

        //日期选择框设置
        laydate.render({
            elem: '#test16'
            ,type: 'datetime'
            ,range: '到'
            ,format: 'yyyy-MM-dd HH:mm:ss'
        });

        //条件查询
        $("#demo1").click(function () {
            let staffname = $("#staffname").val();
            let createdate = $("#test16").val();
            alert(staffname);
            alert(createdate);
            //执行重载
            table.reload('allOut', {
                page: {
                    curr: 1 //重新从第 1 页开始
                }
                ,where: {
                    staffname: staffname,
                    scopedate:createdate
                }
            });
        })


        table.render({
            elem: '#allOut'
            ,url:'${pageContext.request.contextPath}/store/getAllOutInfo'
            // ,toolbar: '#toolbarDemo'
            ,title: '出库申请记录'
            ,totalRow: true
            ,cols: [[
                {type: 'checkbox', fixed: 'left'}
                ,{field:'id', title:'ID', width:80, fixed: 'left', unresize: true, sort: true, totalRowText: '合计'}
                ,{field:'outnumber', title:'申请单编号'}
                ,{field:'staffid', title:'申请人id'}
                ,{field:'staffname', title:'申请人名字'}
                ,{field:'bookcount', title:'总量(本)', width:100, sort: true, totalRow: true}
                ,{field:'bookprice', title:'总价(元)', width:100, sort: true, totalRow: true}
                ,{field:'createdate', title:'创建时间'}
                ,{field:'status', title:'状态', width:110,templet:function (d) {
                        if(d.status==0){
                            return "<button class='layui-btn layui-btn-warm'>待审核</button>";
                        }else if(d.status==1){
                            return "<button class='layui-btn'>审核通过</button>";
                        }else {
                            return "<button class='layui-btn layui-btn-danger'>被驳回</button>";
                        }
                    }}
                ,{fixed: 'right', title:'操作', toolbar: '#historyBarDemo', width:150}
            ]]
            ,page: true
            ,limit:5 //设置一页几条
            ,limits:[5,10,15] //放置可供
        });

        function detailInfo(outnumber){
            table.render({
                elem: '#detailInfo'
                ,url:'${pageContext.request.contextPath}/detail/showInfoBOUT?outnumber='+outnumber
                ,title: '订单详情'
                ,cols: [[
                    // {type: 'checkbox', fixed: 'left'}
                    {field:'id', title:'ID',fixed: 'left',hide:true,unresize: true, sort: true}
                    ,{field:'out_outnumber', title:'出库单编号'}
                    ,{field:'bookname', title:'书名',width:100}
                    ,{field:'price', title:'进价',width:100}
                    ,{field:'bookcount', title:'总量(本)',sort: true,width:120}
                    // ,{field:'count', title:'库存数量'}
                    ,{field:'publisher', title:'出版社',width:120}
                    // ,{field:'disagree', title:'审核意见',edit:true}
                    // ,{fixed: 'right', title:'操作', toolbar: '#barDemo'}
                ]]
                ,page: true
                ,limit:5 //设置一页几条
                ,limits:[5,10,15] //放置可供
            });
        }

        //监听审核记录表的行工具事件
        table.on('tool(allOut)', function(obj){
            var data=obj.data;
            if(obj.event==='allAuditInfo'){
                layer.open({
                    type: 1,
                    content: '<table class="layui-hide" id="detailInfo" lay-filter="detailInfo"></table>', //这里content是一个普通的String
                    success:function () {
                        detailInfo(data.outnumber);
                    }
                });
            }
        });

    });
</script>
</html>
